package com.pengchuang.ACS.admin.boot.service.impl;

import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pengchuang.ACS.common.utils.PageUtils;
import com.pengchuang.ACS.common.utils.Query;

import com.pengchuang.ACS.admin.boot.dao.SysRoleDao;
import com.pengchuang.ACS.admin.boot.entity.SysRoleEntity;
import com.pengchuang.ACS.admin.boot.service.SysRoleService;

@RequiredArgsConstructor
@Service("sysRoleService")
public class SysRoleServiceImpl extends ServiceImpl<SysRoleDao, SysRoleEntity> implements SysRoleService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        // 集成查找功能
        QueryWrapper<SysRoleEntity> query = new QueryWrapper<>();
        if (params.get("name") != null) {
            query.like("name", String.valueOf(params.get("name")));
        }
        if (params.get("code") != null) {
            query.like("code", String.valueOf(params.get("code")));
        }
        IPage<SysRoleEntity> page = this.page(
                new Query<SysRoleEntity>().getPage(params),
                query
        );

        return new PageUtils(page);
    }

}